package com.shopping.service.impl;

import java.util.ArrayList;

import com.shopping.dao.UserDao;
import com.shopping.dao.impl.UserDaoImpl;
import com.shopping.pojo.User;
import com.shopping.service.UserService;

public class UserServiceImpl implements UserService {
	
	private UserDao ud = new UserDaoImpl();
	
	// 判断用户名和密码
	public boolean login(String username, String password) {
		User user = (User) ud.findUserByUsernameAndPassword(username, password);
		if(user != null) {
			return true;
		}
		return false;
	}
	
	// 获取用户信息
	public User getUser(String username, String password) {
		User user = ud.findUserByUsernameAndPassword(username, password);
		return user;
	}
	
	// 注册功能
	public boolean registerUser(User user) {
		boolean b = ud.insert(user);
		if(b)
			return true;
		return false;
	}

	// 获取全部用户信息
	public ArrayList<User> getUserAll() {
		return ud.findAll();
	}
	
	// 分页查询
	public ArrayList<User> getUserPage(int page, int limit) {
		return ud.findPage(page, limit);
	}
	
	// 查询数据总量
	public long getTotalData() {
		return ud.TotalData();
	}
}
